﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Service.RoleInfos;

namespace UI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoleController : ControllerBase
    {
        private readonly IRoleService roleService;

        public RoleController(IRoleService roleService)
        {
            this.roleService = roleService;
        }

        [HttpGet]
        public IActionResult Query()
        {
            return Ok(roleService.Query());
        }

        /// <summary>
        /// 菜单添加
        /// </summary>
        /// <param name="menuDto"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult Insert(RoleDto roleDto)
        {
            return Ok(roleService.Insert(roleDto));
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public IActionResult Delete(int id)
        {
            return Ok(roleService.Delete(id));
        }

        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult QueryFirst(int id)
        {
            return Ok(roleService.QueryFirst(id));
        }

        /// <summary>
        /// 菜单修改
        /// </summary>
        /// <param name="menuDto"></param>
        /// <returns></returns>
        [HttpPut]
        public IActionResult Update(RoleDto roleDto)
        {
            return Ok(roleService.Update(roleDto));
        }
    }
}
